﻿#include "connection.h"
#include "socketlibfunction.h"

SocketLib::ConnectionSocket::ConnectionSocket()
{
}

bool SocketLib::ConnectionSocket::connection(char* aIP, int aPort)
{
    if (!isValid())
    {
        m_fd = SocketApi::MakeConnect(aIP, aPort);
        if (isValid())
        {
            this->setNoBlock(true);
            onConnection();
        }

        return true;
    }

    return false;
}

void SocketLib::ConnectionSocket::disSocket()
{
    SocketLib::SocketApi::CloseSocket(m_fd);

    init();
}
